{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "import tensorflow as tf\r\n",
    "import numpy as np"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "input_data = np.arange(10).reshape(5,2)\r\n",
    "input_data"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "array([[0, 1],\n",
       "       [2, 3],\n",
       "       [4, 5],\n",
       "       [6, 7],\n",
       "       [8, 9]])"
      ]
     },
     "metadata": {},
     "execution_count": 3
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "source": [
    "x1 = tf.keras.layers.Dense(8)(input_data)\r\n",
    "x1"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(5, 8), dtype=float32, numpy=\n",
       "array([[-0.12366056, -0.6986265 ,  0.77080464, -0.24608284,  0.40985382,\n",
       "         0.28273118,  0.30870295, -0.1619857 ],\n",
       "       [ 0.5133357 , -0.72846746,  1.3266207 ,  0.33265072,  2.6006622 ,\n",
       "        -0.22271645,  0.5417254 ,  0.72683674],\n",
       "       [ 1.150332  , -0.7583084 ,  1.8824368 ,  0.91138434,  4.7914705 ,\n",
       "        -0.7281641 ,  0.77474785,  1.6156592 ],\n",
       "       [ 1.7873282 , -0.78814936,  2.438253  ,  1.4901178 ,  6.982279  ,\n",
       "        -1.2336117 ,  1.0077703 ,  2.5044816 ],\n",
       "       [ 2.4243245 , -0.8179903 ,  2.9940686 ,  2.0688515 ,  9.173087  ,\n",
       "        -1.7390594 ,  1.2407928 ,  3.393304  ]], dtype=float32)>"
      ]
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "source": [
    "input_data1 = np.arange(20).reshape(2,2,5)\r\n",
    "input_data1"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "array([[[ 0,  1,  2,  3,  4],\n",
       "        [ 5,  6,  7,  8,  9]],\n",
       "\n",
       "       [[10, 11, 12, 13, 14],\n",
       "        [15, 16, 17, 18, 19]]])"
      ]
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "source": [
    "x2 = tf.keras.layers.Dense(8)(input_data1)\r\n",
    "x2"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 2, 8), dtype=float32, numpy=\n",
       "array([[[ -0.4693585 ,   1.9182044 ,   0.49655652,   2.0242598 ,\n",
       "          -2.4963517 ,  -0.7141022 ,  -1.5666763 ,  -2.8327055 ],\n",
       "        [ -0.7294225 ,   5.189452  ,  -1.713673  ,   2.7146635 ,\n",
       "          -5.2236013 ,  -0.5436924 ,  -0.31653893, -10.431851  ]],\n",
       "\n",
       "       [[ -0.98948634,   8.4607    ,  -3.9239018 ,   3.4050667 ,\n",
       "          -7.9508505 ,  -0.37328255,   0.9335983 , -18.030996  ],\n",
       "        [ -1.2495503 ,  11.731947  ,  -6.134131  ,   4.0954704 ,\n",
       "         -10.6781    ,  -0.20287329,   2.1837363 , -25.630146  ]]],\n",
       "      dtype=float32)>"
      ]
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "source": [
    "x2_f = tf.keras.layers.Flatten()(x2)\r\n",
    "x2_f"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 16), dtype=float32, numpy=\n",
       "array([[ -0.4693585 ,   1.9182044 ,   0.49655652,   2.0242598 ,\n",
       "         -2.4963517 ,  -0.7141022 ,  -1.5666763 ,  -2.8327055 ,\n",
       "         -0.7294225 ,   5.189452  ,  -1.713673  ,   2.7146635 ,\n",
       "         -5.2236013 ,  -0.5436924 ,  -0.31653893, -10.431851  ],\n",
       "       [ -0.98948634,   8.4607    ,  -3.9239018 ,   3.4050667 ,\n",
       "         -7.9508505 ,  -0.37328255,   0.9335983 , -18.030996  ,\n",
       "         -1.2495503 ,  11.731947  ,  -6.134131  ,   4.0954704 ,\n",
       "        -10.6781    ,  -0.20287329,   2.1837363 , -25.630146  ]],\n",
       "      dtype=float32)>"
      ]
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "source": [
    "x3_f = tf.keras.layers.Flatten()(input_data1)\r\n",
    "x3_f"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 10), dtype=int32, numpy=\n",
       "array([[ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9],\n",
       "       [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]])>"
      ]
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  }
 ],
 "metadata": {
  "orig_nbformat": 4,
  "language_info": {
   "name": "python",
   "version": "3.7.1",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.1 64-bit ('KerasEnv': virtualenv)"
  },
  "interpreter": {
   "hash": "49709926ca079d7fc3208f0b0481edbe733516c473689c5f1439ce0f2246de88"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}